{include file="common/mini_header" /}
<div class="login-content-l"></div>
<div class="login-content">
	<div class="login-content-mid">
		<div class="layui-container">
			<div>
				<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
					<ul class="layui-tab-title">
						<li class="layui-this">普通登陆</li>
						<li>手机短信登陆</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-tab-content layui-form-pane">
								<form class="layui-form" action="" method="post">
									<div class="layui-form-item">
										<label class="layui-form-label">手机号：</label>
										<div class="layui-input-inline">
											<input type="tel" name="mobile" lay-verify="required|phone" autocomplete="off" class="layui-input">
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">密码：</label>
										<div class="layui-input-inline">
											<input type="password" name="password" autocomplete="off" class="layui-input">
										</div>
									</div>
                                    <div class="layui-form-item" style="display:none;" id="captcha_div">
                                        <label class="layui-form-label">验证码：</label>
                                        <div class="layui-input-inline" style="width:60px;">
                                            <input type="text" name="captcha" autocomplete="off" id="captcha_ipt" class="layui-input">
                                        </div>
                                        <div class="layui-input-inline" style="width:150px;">
                                            <img src="{:captcha_src()}" id="captcha_img" onclick="setCaptcha()" title="点击更换验证码" alt="captcha" style="max-width:150px;cursor:pointer;" />
                                        </div>
                                    </div>
									<div class="layui-form-item">
										<div class="layui-input-inline">
											<input class="layui-btn layui-btn-fluid" lay-submit lay-filter="password_login" type="submit" value="登录" />
										</div>
									</div>
								</form>
							</div>
						</div>
						<div class="layui-tab-item">
							<div class="layui-tab-content layui-form-pane">
								<form class="layui-form" action="" method="post">
									<div class="layui-form-item">
										<label class="layui-form-label">手机号：</label>
										<div class="layui-input-inline">
											<input type="tel" id="mobile" name="mobile" lay-verify="required|phone" autocomplete="off" class="layui-input">
										</div>
									</div>
									<div class="layui-form-item identifying-code">
										<label class="layui-form-label">短信验证码：</label>
										<div class="layui-input-inline">
											<input type="text" name="code" lay-verify="" autocomplete="off" class="layui-input">
											<input id="btn" class="layui-btn" type="button" style="width:112px;" value="获取验证码" onclick="setSms(this)" />
										</div>
									</div>
									<div class="layui-form-item">
										<div class="layui-input-inline">
											<input class="layui-btn layui-btn-fluid" lay-submit lay-filter="sms_login" type="submit" value="登录" />
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
                <div class="login-b">
				    没有账号？<a href="{:url('b2c/common/reg')}">立即注册</a>
                </div>
			</div>
		</div>
	</div>
</div>	
<div class="login-content-r"></div>
		<script>
			layui.use(['element', 'form'], function() {
				//手机号码登陆
				layui.form.on('submit(sms_login)', function(data) {
					$.ajax({
						type: "POST",
						url: "{:url('b2c/common/smsLogin')}",
						data: data.field,
						success: function(data) {
							if(data.status) {
								layer.msg('登陆成功，跳转中...');
								setTimeout("window.location.href='" + data.data + "'; ", 1500);
							} else {
								layer.msg(data.msg);
							}
						}
					});
					return false;
				});
				//密码登陆
				layui.form.on('submit(password_login)', function(data) {
					$.ajax({
						type: "POST",
						url: "{:url('b2c/common/login')}",
						data: data.field,
						success: function(data) {
							if(data.status) {
								layer.msg('登陆成功，跳转中...');
								setTimeout("window.location.href='" + data.data + "'; ", 1500);
							} else {
                                if(data.data == '10013' || data.data == '10012'){
                                    $('#captcha_div').show();
                                }
                                setCaptcha();
								layer.msg(data.msg);
							}
						}
					});
					return false;
				});
			});
			//发送短信验证码
			function setSms(obj) {
				$.ajax({
					type: "POST",
					url: "{:url('b2c/common/sms')}",
					data: "mobile=" + $('#mobile').val() + "&code=login",
					success: function(data) {
						if(data.status) {
							sms_btn_time($(obj));
						}
						layer.msg(data.msg);
					}
				});
			}
            //更改验证码图片
            function setCaptcha() {
                $('#captcha_ipt').val("");
                var timestamp=new Date().getTime();
                $('#captcha_img').attr('src','{:captcha_src()}?'+timestamp);
            }
		</script>
		{include file="common/mini_footer" /}